package gui.layer;

import java.io.IOException;

/**
 * Class for the Rabbit layer.
 * @author Sandra Mayer
 *
 */
public class RabbitTiledLayer extends BaseLayer {
	
	public final static String FILENAME = "/rabbit.png";
	
	/**
	 * Constructor.
	 * @throws IOException IOException
	 */
	public RabbitTiledLayer() throws IOException {
		super(BaseLayer.NROFCELLSHOR,
				BaseLayer.NROFCELLSVER, FILENAME,
				BaseLayer.SIZEOFCELL, BaseLayer.SIZEOFCELL);
	}
	
	/**
	 * Updates the game field with the new position of the rabbits.
	 * @param posOfRabbits the position of the rabbits
	 */
	public void update(int[] posOfRabbits) {
	  
	  // set the background with the images
	  for (int i = 0; i < posOfRabbits.length; i++) {
	    int column = i % NROFCELLSHOR;
	    int row = (i - column)/NROFCELLSHOR;
	    this.setCell(column, row, posOfRabbits[i]);
	  }
	  
	  // set the location of the background
	  this.setPosition(GAME_ORIGIN_X, GAME_ORIGIN_Y); 
	}
}
